/*
 * Copyright (c) 2011 by Konstantin Pavlov.
 */

package gwtlx.util.client;

/**
 * GWT Utility class.
 *
 * @author Konstantin Pavlov
 * @version $LastChangedRevision: 15 $
 * @since 08.06.2010
 */
public abstract class Utils {

    public static String toJSON(Object o) {
        return toJsonInternal(o);
    }

    /**
     * Returns JSON string representation of given object.
     *
     * @param o object to transfer
     * @return empty string if parameter is null
     */
    private static native String toJsonInternal(Object o) /*-{
        if (!o) return "";
        if (JSON) {
            return JSON.stringify(o);
        } else {
            return o.toString();
        }
    }-*/;
}
